﻿jQuery(function () {
    //如果是列表模式
    //    ;
    $("#tabs").tabs(); //显示Tab页//所有
    if (wmsCommon.getQueryValue('opt') == '0' || wmsCommon.checkForNull(wmsCommon.getQueryValue('opt')) == "") {
        //wmsCommon.addListClass(); //增加列表样式
    }
    //setTreeContentHeight();

    function isString(str) {
        return (typeof str == 'string') && str.constructor == String;
    }
    function ToDateTime(dateTimeStr) {
        return new Date(eval(dateTimeStr.substr(1, dateTimeStr.length).substr(0, dateTimeStr.length - 2))).toLocaleDateString();
    }

    //初始化checkboxtree
    function InitCheckTree(expr) {
        var data = wmsCommon.execCommand(expr);
        FileCheckTree();
    }

    if (wmsCommon.getQueryValue("model") != "") {
        //;
        var opttype = wmsCommon.getQueryValue("opt");
        if (opttype == "" || opttype == "0")
            InitTotalInfo(wmsCommon.getQueryValue('querycon'));
    }
});

//获取列表复选框checked 数据
function wms_check_cb(obj, i) {
    currentModel[i].checked = obj.checked;
}
//获取role得到所有选中的行的roleCode 或 roleName
function getSelectedItems(type) {
    var list = new Array();
    for (var i = 0; i < currentModel.length; i++) {
        var row = currentModel[i];
        if (row.checked != undefined && row.checked == true)
            list[list.length] = row;
    }
    if (type == 'key') {
        for (var j = 0; j < list.length; j++) {
            list[j] = list[j].roleCode.toString();
        }
    }
    else if (type == "text") {
        for (var j = 0; j < list.length; j++) {
            list[j] = list[j].roleName.toString();
        }
    }
    return list;
}

//设置 tree 的外层容器样式
wmsCommon.setTreeContentStyle = function () {
    if (document.getElementById('treeContent')) {
        var thisBody = $('body');
        var treeContent = document.getElementById('treeContent');
        treeContent.style.height = thisBody.outerHeight() * 0.9; //设置高度
        treeContent.style.width = thisBody.innerWidth() * 0.95; //设置宽度
    }
}

//设置 列表 样式
wmsCommon.onMouseOut = function (item) {
    item.style.backgroundColor = "";
};

wmsCommon.onMouseOver = function (item) {
    item.style.backgroundColor = "rgb(255,255,221)";
}

//设置 div百分比样式  //列表样式
wmsCommon.setListDivStyle = function (divId, widthRent) {

    if (document.getElementById(divId)) {
        var thisBody = $('body');
        var div = document.getElementById(divId);
        if (wmsCommon.checkForNull(widthRent) == "") widthRent = 0.98;
        var searchID = document.getElementById("tblSearch");
        if (searchID != null) {
            if (searchID.style.display == "none") {
                div.style.height = (thisBody.innerHeight()) - 90; //设置高度
            } else {
                div.style.height = (thisBody.innerHeight()) - (90 + searchID.scrollHeight); //设置高度
            }
        }
        else {
            div.style.height = (thisBody.innerHeight()) - 150; //设置高度
        }
        div.style.width = (thisBody.innerWidth() - 10) * widthRent;  //设置宽度
        div.style.overflowY = "scroll";
        div.style.overflowX = "auto";
    }
}

//设置 div百分比样式  //列表样式
wmsCommon.setDeskTopDivStyle = function (divId, widthRent) {

    if (document.getElementById(divId)) {
        var thisBody = $('body');
        var div = document.getElementById(divId);
        if (wmsCommon.checkForNull(widthRent) == "") widthRent = 0.98;
            div.style.height = (thisBody.innerHeight()) - 30; //设置高度
        div.style.width = (thisBody.innerWidth() - 10) * widthRent;  //设置宽度
        div.style.overflowY = "scroll";
        div.style.overflowX = "auto";
    }
}

//设置整页为tree 的样式  如岗位授权树
//divId div 容器id ,宽度比例0<x<1;subHeight:减去的绝对高度;
wmsCommon.setTreeDivStyle = function (divId, widthRent, subHeight) {
//    ;
    if (document.getElementById(divId)) {
        var thisBody = $('body');
        var div = document.getElementById(divId);
        if (wmsCommon.checkForNull(widthRent) == "") widthRent = 0.98;
        if (subHeight)
            div.style.height = (thisBody.innerHeight()) - subHeight; //设置高度
        else
            div.style.height = (thisBody.innerHeight());
        div.style.width = (thisBody.innerWidth() - 10) * widthRent; //设置宽度
        div.style.overflowY = "auto";
        div.style.overflowX = "auto";
    }
}
//改变窗口大小触发事件
function changeWindowSize  () {
}



wmsCommon.setEditDivStyle = function (divId, widthRent) {
    if (document.getElementById(divId)) {
        var thisBody = $('body');
        var div = document.getElementById(divId);
        if (wmsCommon.checkForNull(widthRent) == "") widthRent = 0.98;
        var MainInfo = document.getElementById("contenttb");
        if (MainInfo != null) {
                div.style.height = (thisBody.innerHeight()) - (100 + MainInfo.scrollHeight); //设置高度  
        }
        else {
            div.style.height = (thisBody.innerHeight()) - 140; //设置高度
        }

        div.style.width = (thisBody.innerWidth() - 20) * widthRent;  //设置宽度
        div.style.overflowY = "scroll";
        div.style.overflowX = "auto";
    }
}